﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProduceBasicData.Api.Application.Command.RBAC.OperLog;
using ProduceBasicData.Api.DTO.RBACDto;
using ProduceBasicData.ErrorCode;

namespace ProduceBasicData.Api.Controllers.RBAC
{
    /// <summary>
    /// 系统日志控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OperLogsController : ControllerBase
    {
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public OperLogsController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 创建系统日志
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateOperLog(CreateOperLogCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 获取系统日志列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<OperLogsDto>> GetOperLogList([FromQuery] GetOperLogCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
